<div id="assetList">
  <div class="listOptions">
    <span><a href="{$site_url}/?module=assets{if $corp}&corp=1{/if}">All assets, by location</a></span>
    <span><a href="{$site_url}/?module=assets{if $corp}&corp=1{/if}&type=ships">Ships</a></span>
    <span>Group: 
      <select id="group" onchange="window.location='{$site_url}/?module=assets{if $corp}&corp=1{/if}&group='+this.value">
        <option value="0" {if $group == 0}selected="selected"{/if}>All</option>
        {foreach from=$groups item=grp}
        <option value="{$grp.groupid}" {if $group == $grp.groupid}selected="selected"{/if}>{$grp.groupname}</option>
        {/foreach}
      </select>
    </span>
    <span>Search: 
      <input type="text" id="assetFind" value="{$search}" /> 
      <button onclick="window.location='{$site_url}/?module=assets{if $corp}&corp=1{/if}&type=find&item='+$('#assetFind').val()">Go</button>
    </span>
  </div>
  {if $pageCount > 0}
  <div align="right">
    {if $prevPage < $pageNum}
    <button onclick="window.location='{$site_url}/?module=assets{if $corp}&corp=1{/if}&p={$prevPage}'" class="pageNav"> &lt;&lt; </button>
    {/if}
    &nbsp; pg {$pageNum+1} / {$pageCount} &nbsp;
    {if $nextPage < $pageCount}
    <button onclick="window.location='{$site_url}/?module=assets{if $corp}&corp=1{/if}&p={$nextPage}'" class="pageNav"> &gt;&gt; </button>
    {/if}
  </div>
  {/if}

  <table width="100%" border="0">
    <tr>
      <th width="40%">Item</th>
      <th width="25%">Group</th>
      <th width="25%">Location</th>
      <th width="10%">Quantity</th>
    </tr>
    {foreach from=$assets item=lol key=locid}
    <tr class="groupHead shadeDark borderDark textLight assetGroup" data-assetid="{$locid}">
      <td colspan="3">
        {if $lol.location.stationid}
        <img src="{$site_url}/{$lol.location.icon.icon32}" class="i32" alt="{$lol.location.stationname}" align="absmiddle" />
        {/if}
        {$lol.locationName}
      </td>
      <td align="right">
        {$lol.assets|@count}
      </td>
    </tr>
    <tr>
      <td colspan="4">
        <div style="display:none" id="{$locid}">
          {foreach from=$lol.assets item=ass name='foo'}
          {if !$ass.hide}
          {include file="assetlist.html" asset=$ass last=$smarty.foreach.foo.last}
          {/if}
          {/foreach}
        </div>
      </td>
    </tr>
    {/foreach}
  </table>

  {if !$assets}
  <h3>{if $corp}Your corporation has{else}You have{/if} no assets!</h3>
  {/if}

</div>

<script type="text/javascript">
  $(document).ready(function() {
    $('.assetGroup').each(function() {
      $(this).css('cursor', 'pointer');
      $(this).click(function() {
        $('#' + $(this).data('assetid')).toggle('fast');
      });
    });
    
  });
</script>